import {
  ADD_TAG,
  SELECT_TAG,
  SELECT_CATEGORY,
  EDIT_NOTELABEL,
  EDIT_AMOUNT,
  MODIFY_TAG,
  REMOVE_TAG,
  ADD_RECORD,
} from "./actiontypes";

export const addTag = (tag: TagType, category: string) => {
  return {
    type: ADD_TAG,
    payload: {
      tag,
      category,
    },
  };
};
export const selectTag = (tags: TagType[]) => {
  return {
    type: SELECT_TAG,
    payload: {
      tags,
    },
  };
};

export const selectCategory = (index: string) => {
  return {
    type: SELECT_CATEGORY,
    payload: {
      index,
    },
  };
};
export const editLabel = (content: string) => {
  return {
    type: EDIT_NOTELABEL,
    payload: {
      content,
    },
  };
};
export const setAmount = (amount: number) => {
  return {
    type: EDIT_AMOUNT,
    payload: {
      amount,
    },
  };
};
export const modifyTag = (
  tagName: string,
  tagIcon: React.FC,
  i: string,
  oldTagName: string
) => {
  return {
    type: MODIFY_TAG,
    payload: {
      oldTagName,
      i,
      tagName,
      tagIcon,
    },
  };
};
export const removeTag = (tName: string, cate: string) => {
  return {
    type: REMOVE_TAG,
    payload: {
      tName,
      cate,
    },
  };
};
export const addRecord = (
  id: string,
  tags: TagType[],
  createdAt: string,
  amount: number,
  category: string,
  note: string,
) => {
  return {
    type: ADD_RECORD,
    payload: {
      id,tags,createdAt,amount,category,note
    }
  }

};
